from django.db import models

# Create your models here.
from django.utils import timezone

from common.models import Person


class LeaveRecord(models.Model):
    person = models.ForeignKey(to=Person, verbose_name="请假人", on_delete=models.CASCADE, related_name="leave_record")
    account = models.DecimalField(verbose_name="请假天数", max_digits=99999, decimal_places=2)
    leave_time = models.DateField(verbose_name="请假时间", default=timezone.now)
    record_time = models.DateTimeField(verbose_name="记录时间", auto_now=True)
    reason = models.TextField(verbose_name="原因", blank=True, null=True)

    def __str__(self):
        return str(self.person)

    class Meta:
        ordering = ('-pk',)
        verbose_name = '请假记录'
        verbose_name_plural = verbose_name
